package main

import (
	"gvb_service/database"
	cors_middleware "gvb_service/middleware/cors"
	unauth_router "gvb_service/router/unauth"
	user_router "gvb_service/router/user"

	"github.com/gin-gonic/gin"
	"github.com/spf13/viper"
)

func main() {
	InitConfig()
	database.MysqlInit()
	database.RedisInit()
	r := gin.Default()
	// 处理跨域
	r.Use(cors_middleware.CORS())
	unauth_router.UnauthRouterInit(r)
	user_router.UserRouterInit(r)
	panic(r.Run(viper.GetString("server.port")))
}

func InitConfig() {
	viper.SetConfigFile("./application.yaml")
	err := viper.ReadInConfig()
	if err != nil {
		panic(err)
	}
}
